package com.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.bean.Course;

public class CourseDao extends DaoUtil {
	private PreparedStatement stat = null;
	private Connection conn = null;
	private ResultSet rs = null;
	
	public List<Course> getCourseList(){
		List<Course> courseList = new ArrayList<Course>();
		String sql = "select * from course";
		conn = this.getConnection();
		try {
			stat = conn.prepareStatement(sql);
			rs = stat.executeQuery();
			while(rs.next()){
				Course course = new Course();
				course.setCourseID(rs.getInt("courseID"));
				course.setCourseName(rs.getString("courseName"));
				course.setAvailableTeacher(rs.getString("availableTeacher"));
				course.setCoursePoint(rs.getString("coursePoint"));
				courseList.add(course);
			}
			return courseList;
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		} finally{
			closed();
		}
		
	}
	
}
